#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* make hash */
char *s16h(const char *szIn, char *szOut) {
  int iTable[4];
  int  iCycle = 0;
  int  iHash[16];
  

  strcpy(szOut, "");  
  if(!szIn[0]) return szOut;
  
  iTable[0] = 0x90CE;
  iTable[1] = 0x1234;
  iTable[2] = 0xF13D;
  iTable[3] = 0x4A83;
  iTable[4] = 0xB379;

  for(iCycle = 0; iCycle < 8; iCycle++) {
    iHash[iCycle] = ((szIn[iCycle%strlen(szIn)] / 2) * szIn[iCycle%strlen(szIn)] ^ iTable[iCycle%4]) + iTable[iCycle%4];
    iHash[iCycle] &= 0xFFFF;
    sprintf(szOut, "%s%02x", szOut, iHash[iCycle]);
  }
  return szOut;
}

int main(int argc, char **argv) {
  char *szHash    = malloc(64);
  s16h(argv[2], szHash);
  printf("%s\n%s", argv[1], szHash);
  return 0;
}
